home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / Library & Plugs / RossetMADF Library 68K & PPC / Example.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-11  |  2.7 KB  |  139 lines  |  [TEXT/KAHL]

  1. //
  2. //        Example of MADF Library
  3. //        Copyright 1994 Antoine ROSSET
  4. //
  5. //
  6. //        FREEWARE
  7.  
  8.  
  9. #include "MAD.h"
  10. #include "RDriver.h"
  11. #include "gestaltequ.h"
  12. #include "sound.h"
  13.  
  14. static     Boolean        Stereo, StereoMixing, NewSoundManager, hasASC;
  15.  
  16. void MyDebugStr( Str255 theStr);
  17.  
  18. void MyDebugStr( Str255 theStr)
  19. {
  20.     // MusicDriver return FATAL error in this function
  21.     
  22.     DebugStr( theStr);
  23. }
  24.  
  25. main()
  26. {
  27. long            gestaltAnswer;
  28. int                myBit;
  29. NumVersion        nVers;
  30. Point            where = { -1, -1};
  31. SFReply            reply;
  32. SFTypeList        aType;
  33.  
  34. InitGraf( &qd.thePort);
  35. InitFonts();
  36. FlushEvents(everyEvent,0);
  37. InitWindows();
  38. TEInit();
  39. InitMenus();
  40. InitCursor();
  41. MaxApplZone();
  42.  
  43. /****** HARDWARE IDENTIFICATION AND CHECK **********/
  44.  
  45. /** ASC CHIP ? **/
  46.  
  47. Gestalt( gestaltHardwareAttr, &gestaltAnswer);
  48. myBit = gestaltHasASC;
  49. if( BitTst( &gestaltAnswer, 31-myBit) == false) hasASC = false;
  50. else hasASC = true;
  51.  
  52. /** STEREO ? **/
  53.  
  54. Gestalt( gestaltSoundAttr, &gestaltAnswer);
  55. myBit = gestaltStereoCapability;
  56. Stereo = BitTst( &gestaltAnswer, 31-myBit);
  57.  
  58. /** STEREO MIXING ? **/
  59.  
  60. myBit = gestaltStereoMixing;
  61. StereoMixing = BitTst( &gestaltAnswer, 31-myBit);
  62.  
  63. /** SOUND MANAGER >3.0 ? **/
  64.  
  65. nVers = SndSoundManagerVersion();
  66. if( nVers.majorRev >= 3) NewSoundManager = true;
  67. else NewSoundManager = false;
  68. /****************************************************/
  69.  
  70.  
  71. /****** CHOOSE A MADF File ********/
  72. aType[ 0] = 'MADF';
  73. SFGetFile( where, "\p", 0L, 1, aType, 0L, &reply);
  74. SetVol( 0L, reply.vRefNum);
  75.  
  76.  
  77. /*** To load a MADF File *********/
  78. if( RLoadMOD( reply.fName) != noErr) Debugger();
  79.  
  80.  
  81. /*
  82.     TO OPEN A MADF RESOURCE
  83.  
  84.     To create a MADF Resource, use Auto-Exec export from Player PRO !!!!
  85.  
  86.     And load the resource with: by example...
  87.  
  88.     RLoadMADFRsrc( 'MADF', 3124);
  89. */
  90.  
  91. /*********************************/
  92.  
  93. /********* MADF Library Initialisation : choose the best driver for the current hardware ******/
  94.  
  95. if( Stereo == true && StereoMixing == true)
  96. {        
  97.     if( NewSoundManager == true)
  98.     {
  99.         if( RInitMOD( SMStereo, thePartition.header->Tracks) != noErr) ExitToShell();
  100.     }
  101.     else if( hasASC == true)
  102.     {
  103.         if( RInitMOD( ASCStereo, thePartition.header->Tracks) != noErr) ExitToShell();
  104.     }
  105.     else if( RInitMOD( SMDSP, thePartition.header->Tracks) != noErr) ExitToShell();
  106. }
  107. else
  108. {        
  109.     if( NewSoundManager == true)
  110.     {
  111.         if( RInitMOD( SMMono, thePartition.header->Tracks) != noErr) ExitToShell();
  112.     }
  113.     else if( hasASC == true)
  114.     {
  115.         if( RInitMOD( ASCMono, thePartition.header->Tracks) != noErr) ExitToShell();
  116.     }
  117.     else DebugStr("\pNo Driver for your Mac!");
  118. }    
  119.  
  120. RPlayMOD();
  121. Reading = true;
  122.  
  123. while( !Button())
  124. {
  125.     /** Do what you want here.... **/
  126.     
  127.     /* Bla bla...*/
  128. }
  129.  
  130.  
  131. RStopMOD();            // Stop music
  132. RClearMOD();        // Clear MADF Music
  133. RQuitMOD();            // Clear MADF Driver
  134.  
  135. FlushEvents( everyEvent, 0);
  136. ExitToShell();
  137. }
  138.  
  139.